home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / g_mouse.zip / DEMOMOUS.PAS next >
Pascal/Delphi Source File  |  1992-09-23  |  7KB  |  175 lines

  1. Program Demo_Mouse;
  2.  
  3. Uses Crt,Dos,Graph,G_Mouse;
  4.  
  5. Var x, y, button, b: Word;
  6.     i:integer;
  7.     Condition:boolean;
  8.  
  9. Procedure Init;
  10.   Var GrD, GrM : Integer;
  11.   Begin
  12.     DetectGraph (GrD,GrM);
  13.     InitGraph (GrD,GrM,'c:\tp\bgi');
  14.     If Not TestMouse Then Begin
  15.       SetTextJustify (CenterText, CenterText);
  16.       SetTextStyle (DefaultFont, HorizDir, 5);
  17.       OutTextXY (Round (GetMaxX/2), Round (GetMaxY/2), 'You need a mouse driver !');
  18.       Repeat Until KeyPressed;
  19.       Halt;
  20.     End;
  21.     ChangeMouse(Arrow);
  22.   End;
  23.  
  24.   Procedure Title;
  25.   Begin
  26.     SetTextStyle (1, HorizDir, 6);
  27.     SetTextJustify (CenterText, TopText);
  28.     OutTextXY (Round (GetMaxX/2), 5, 'UNIT MOUSE');
  29.     SetTextJustify (CenterText, BottomText);
  30.     OutTextXY (Round (GetMaxX/2), GetMaxY-5, 'DEMO');
  31.   End;
  32.  
  33. Begin
  34.   Init;
  35.   SetColor (13);
  36.   Title;
  37.   SetTextJustify (LeftText, CenterText);
  38.   SetTextStyle(1, HorizDir, 3);
  39.   SetColor (15);
  40.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*4), 'This unit allows you to show or hide');
  41.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*5), 'the mouse. This is usefull when you draw');
  42.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*6), 'on the background...');
  43.   Box (Round (GetMaxX/2), Round (GetMaxY/2), GetMaxX, 30,0,0,2,'Click to hide the mouse');
  44.   Show_Mouse;
  45.   Repeat MouseState (x,y,button) Until button<>0;
  46.   Hide_Mouse;
  47.   Repeat MouseState (x,y,button) Until button=0;
  48.   Box (Round (GetMaxX/2), Round (GetMaxY/2), GetMaxX, 30,0,0,2,'Click to show the mouse');
  49.   Repeat MouseState (x,y,button) Until button<>0;
  50.   Box (Round (GetMaxX/2), Round (GetMaxY/20*15), 120, 30,9,3,1,'Continue');
  51.   Show_Mouse;
  52.   WaitBox (Round (GetMaxX/2)-60,Round (GetMaxY/20*15)-15,Round (GetMaxX/2)+60,Round (GetMaxY/20*15)+15,Left);
  53.   Hide_Mouse;
  54.   ClearViewPort;
  55.  
  56.   SetColor (11);
  57.   Title;
  58.   SetTextJustify (LeftText, CenterText);
  59.   SetTextStyle(1, HorizDir, 3);
  60.   SetColor (15);
  61.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*4), 'This unit allows you to create easily selection');
  62.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*5), 'boxes, and wait the user click one of them...');
  63.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*6), 'with the button you want...');
  64.   Box (Round (GetMaxX/4), Round (GetMaxY/2), 120, 30,10,2,1,'Left');
  65.   If KindOfMouse=3 Then
  66.     Box (Round (GetMaxX/2), Round (GetMaxY/2), 120, 30,10,2,1,'Center');
  67.   Box (Round (GetMaxX/4*3), Round (GetMaxY/2), 120, 30,10,2,1,'Right');
  68.   Box (Round (GetMaxX/2), Round (GetMaxY/20*15), 120, 30, 9, 3, 1,'Continue');
  69.   SetTextJustify (LeftText, CenterText);
  70.   SetTextStyle(1, HorizDir, 3);
  71.   SetColor (12);
  72.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*12), 'Try at it on each of those boxes...');
  73.   Show_Mouse;
  74.   Repeat                                                         
  75.     MouseState (x,y,button);
  76.     If (((y>Round(GetMaxY/2)-15) And (y<Round (GetMaxY/2)+15)) And
  77.        (((x>Round (GetMaxX/4)-60) And (x<Round (GetMaxX/4)+60) And (button=Left)) Or
  78.        ((x>Round (GetMaxX/2)-60) And (x<Round (GetMaxX/2)+60) And (KindOfMouse=3) And (button=Middle)) Or
  79.        ((x>Round (GetMaxX/4*3)-60) And (x<Round (GetMaxX/4*3)+60) And (button=Right)))) Then Begin
  80.           Sound (1000);
  81.           Delay (100);
  82.           NoSound;
  83.     End;
  84.   Until Testbutton(Round (GetMaxX/2)-60,Round(GetMaxY/20*15)-15,Round (GetMaxX/2)+60,Round (GetMaxY/20*15)+15,Left);
  85.   Hide_Mouse;
  86.   ClearViewPort;
  87.  
  88.   SetColor (12);
  89.   Title;
  90.   SetTextJustify (LeftText, CenterText);
  91.   SetTextStyle(1, HorizDir, 3);
  92.   SetColor (15);
  93.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*4), 'This unit allows you to change the mouse cursor');
  94.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*5), 'There are 4 predefined cursors in constants and');
  95.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*6), 'you can define new cursor...in an easy way...');
  96.   SetColor(2);
  97.   SetTextJustify (CenterText, CenterText);
  98.   OutTextXY (Round (GetMaxX/2), Round (GetMaxY/2), 'Click right button to change the cursor');
  99.   Box (Round(GetMaxX/2),Round(GetMaxY/20*15),120,30,9,3,1,'Continue');
  100.   Show_Mouse;
  101.   i:=0;
  102.   Condition:=False;
  103.   Repeat
  104.     Waitbutton(x,y,button);
  105.     Case button Of
  106.       Left  : If ((x>(Round(GetMaxX/2)-60)) And (x<(Round(GetMaxX/2)+60))) And
  107.                   ((y>(Round(GetMaxY/20*15)-15)) And (y<(Round(GetMaxY/20*15)+15))) Then
  108.                   Condition:=True;
  109.       Right : Begin
  110.                 Inc (i);
  111.                 i:= i Mod 4;
  112.                 Case i Of
  113.                   0 : ChangeMouse (Arrow);
  114.                   1 : ChangeMouse (Target);
  115.                   2 : ChangeMouse (Bomb);
  116.                   3 : ChangeMouse (QuestionMark);
  117.                 End;
  118.               End;
  119.     End;
  120.   Until Condition;
  121.   Hide_Mouse;
  122.   ClearViewPort;
  123.  
  124.   SetColor (9);
  125.   Title;
  126.   SetTextJustify (LeftText, CenterText);
  127.   SetTextStyle(1, HorizDir, 3);
  128.   SetColor (15);
  129.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*4), 'This unit allows you to define a area out of');
  130.   OutTextXY (Round (GetMaxX/15), Round (GetMaxY/20*5), 'which the mouse can''t go...');
  131.   Show_Mouse;
  132.   PutMouse(0,0);
  133.   MouseLimits (Round(GetMaxX/2)-150,Round(GetMaxY/2)-50,Round(GetMaxX/2)+150,Round(GetMaxY/2)+50);
  134.   b:=0;
  135.   Repeat
  136.     Hide_Mouse;
  137.     Box (Round(GetmaxX/2), Round(GetMaxY/2),300,100,14,8,2,'Limited area');
  138.     Show_Mouse;
  139.     For i:=0 To 10000 Do Begin
  140.        MouseState (x,y,Button);
  141.        If button<>0 Then b:=button;
  142.     End;
  143.     Hide_Mouse;
  144.     Box (Round(GetmaxX/2), Round(GetMaxY/2),300,100,14,8,2,'Click To Continue');
  145.     Show_Mouse;
  146.     For i:=0 To 10000 Do Begin
  147.        MouseState (x,y,Button);
  148.        If button<>0 Then b:=button;
  149.     End;
  150.   Until b<>0;
  151.   Hide_Mouse;
  152.   ClearViewPort;
  153.  
  154.   SetColor (10);
  155.   Title;
  156.   SetTextJustify (CenterText, CenterText);
  157.   SetTextStyle(1, HorizDir, 3);
  158.   SetColor (15);
  159.   OutTextXY (Round (GetMaxX/2), Round (GetMaxY/20*6), 'All in all, you''ll find 12 procedures, 2 functions,');
  160.   OutTextXY (Round (GetMaxX/2), Round (GetMaxY/20*7), 'few constants and types in the unit G_MOUSE.TPU');
  161.   OutTextXY (Round (GetMaxX/2), Round (GetMaxY/20*8), 'All details are in the file USER.TXT.');
  162.   OutTextXY (Round (GetMaxX/2), Round (GetMaxY/20*9), 'I wish you a lot of fun and nice new graphic');
  163.   OutTextXY (Round (GetMaxX/2), Round (GetMaxY/20*10), 'programs with your MOUSE...!');
  164.   UnLimitMouse;
  165.   Show_Mouse;
  166.   Repeat
  167.     x:=Random (GetMaxX);
  168.     y:=Random (GetMaxY);
  169.     PutMouse (x,y);
  170.     Delay (100);
  171.     MouseState (x,y,button);
  172.   Until button<>0;
  173.   Hide_Mouse;
  174.   ClearViewPort;
  175. End.